package org.example.memberlist_back.server;

import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import org.example.memberlist_back.common.Res;
import org.example.memberlist_back.entity.Member;
import org.example.memberlist_back.mapper.MemberMapper;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;

@Service
public class MemberServerImpl  extends ServiceImpl<MemberMapper, Member> implements  MemberServer {
    @Autowired
    private MemberMapper memberMapper;
    public Res<String> addUser(Member member){
        memberMapper.addUser(member);
        return Res.success("添加成功");
    }
    public Res<String> deleteUser(String id){
        memberMapper.deleteUserByUsername(id);
        return Res.success("删除成功");
    }
    public Res<String> updateUser(Member member){
        memberMapper.updateUser(member);
        return Res.success("修改成功");
    }

    @Override
    public Res<List<Member>> getMemberList() {
        return  new Res<>(200,"获取成功",memberMapper.selectAllUsers());
    }
}
